- content_for(:title) do
  | 融资管理

.row.top-blank
  .small-12.columns
    .back-link
      = link_to edit_project_path(@project) do
        | 回到项目
        span <

.money-require-admin ng-controller='MoneyRequireAdminController' ng-init='init(#{@project.id}, {})'
  .row
    .small-12.columns
      .nav-head
        ul.small-block-grid-1.medium-block-grid-5.list
          li
            a ng-class='{ active: money_require.status == "ready" || !money_require }'
              | 1. 融资预热
          li
            a ng-class='{ active: money_require.status == "leader_needed" }'
              | 2. 预热中
          li
            a ng-class='{ active: money_require.status == "leader_need_confirmed" }'
              | 3. 领投人确认
          li
            a ng-class='{ active: money_require.status == "opened" }'
              | 4. 融资中
          li
            a ng-class='{ active: money_require.status == "closed" }'
              | 5. 融资结束

  // 融资预热
  .row.ng-cloak ng-show=' !loading && money_require && ( money_require.status == null || money_require.status == "ready")  || ! money_require'
    .small-12.large-10.large-centered.columns
      form ng-submit= 'create_or_update()'
        h4.title 创建新的一轮融资
        label for="money" 计划融资
        .row.collapse
          .small-1.columns
            span.prefix ¥
          .small-11.medium-8.large-6.end.columns
            input type='text' id='money' ng-model='money_require.money' ng-class='{ error: money_require.errors.money }' placeholder="输入融资额度"
            small.error ng-show='money_require.errors.money' {{ money_require.errors.money }}
        label for="share" 出让股份
        .row.collapse
          .small-11.medium-3.columns
            input type='text' id='share' ng-model='money_require.share' ng-class='{ error: money_require.errors.share }' placeholder='建议: 5%-20%'
            small.error ng-show='money_require.errors.share' {{ money_require.errors.share }}
          .small-1.large-1.end.columns
            span.postfix %
        label for='prevalue' 融资前估值( 自动计算 )
        .row.collapse
          .small-11.medium-8.large-6.end.columns
            input type='text' id='money' ng-value='prevalue() | nfcurrency' disabled='' 
        label for='deadline' 融资周期
        .row.collapse
          .small-11.medium-3.columns
            input type='text' id='deadline' ng-model='money_require.deadline' ng-class='{ error: money_require.errors.deadline }' placeholder='建议: 30-60 天'
            small.error ng-show='money_require.errors.deadline' {{ money_require.errors.deadline }}
          .small-1.large-1.end.columns
            span.postfix 天
        label for='maxnp' 限制最大人数
        .row.collapse
          .small-12.medium-3.columns
            input type='text' id='maxnp' ng-model='money_require.maxnp' ng-class='{ error: money_require.errors.maxnp }' placeholder='建议: #{MoneyRequire::NP_MIN} - #{MoneyRequire::NP_MAX} 人'
            small.error ng-show='money_require.errors.maxnp' {{ money_require.errors.maxnp }}
          .small-1.large-1.end.columns
            span.postfix 人
        p.alert 以上填入你的期望值, 在融资开始前均可以修改.
        button.ng-cloak ng-hide='money_require.id' 创建并预热
        button.ng-cloak ng-show='money_require.id'  开始预热
  .row.ng-cloak ng-show='money_require.status == "leader_needed"'
    .small-12.large-10.large-centered.columns
      h4.title 1. 融资预热中, 你可以:
      p
        ul
          li
            p
              | 预热融资, 联系平台上优秀的 
              = link_to '投资人', investors_path, target: '_blank'
          li
            p 找到领投人, 键入他的平台名字或邮箱确认融资条款
          li.ng-cloak
            | 我要 
            a ng-click='opened_menu = !opened_menu' ng-init='opened_menu = false' 调整融资
            p
              form ng-submit= 'create_or_update()' ng-show='opened_menu'
                label for="money" 计划融资
                .row.collapse
                  .small-1.columns
                    span.prefix ¥
                  .small-11.medium-8.large-6.end.columns
                    input type='text' id='money' ng-model='money_require.money' ng-class='{ error: money_require.errors.money }' placeholder="输入融资额度"
                    small.error ng-show='money_require.errors.money' {{ money_require.errors.money }}
                label for="share" 出让股份
                .row.collapse
                  .small-11.medium-3.columns
                    input type='text' id='share' ng-model='money_require.share' ng-class='{ error: money_require.errors.share }' placeholder='建议: 5%-20%'
                    small.error ng-show='money_require.errors.share' {{ money_require.errors.share }}
                  .small-1.large-1.end.columns
                    span.postfix %
                label for='prevalue' 融资前估值( 自动计算 )
                .row.collapse
                  .small-11.medium-8.large-6.end.columns
                    input type='text' id='money' ng-value='prevalue() | nfcurrency' disabled='' 
                label for='deadline' 融资周期
                .row.collapse
                  .small-11.medium-3.columns
                    input type='text' id='deadline' ng-model='money_require.deadline' ng-class='{ error: money_require.errors.deadline }' placeholder='建议: 30-60 天'
                    small.error ng-show='money_require.errors.deadline' {{ money_require.errors.deadline }}
                  .small-1.large-1.end.columns
                    span.postfix 天
                label for='maxnp' 限制最大人数
                .row.collapse
                  .small-12.medium-3.columns
                    input type='text' id='maxnp' ng-model='money_require.maxnp' ng-class='{ error: money_require.errors.maxnp }' placeholder='建议: #{MoneyRequire::NP_MIN} - #{MoneyRequire::NP_MAX} 人'
                    small.error ng-show='money_require.errors.maxnp' {{ money_require.errors.maxnp }}
                  .small-1.large-1.end.columns
                    span.postfix 人
                button.ng-cloak ng-show='money_require.id' 更新
      hr
      h4 2. 领投人确认环节
      p 
        | 我已经线下谈好领投人, 现在去 
        a ng-click='open_leader_confirm_modal()' 确认
      script type='text/ng-template' id='leader_confirm_modal.html'
        .row.leader-confirm-modal
          a.close-reveal-modal ng-click="cancel()" ×
          .small-12.columns
            h3.title 领投协议确认
            ol
              li 
                h4 融资条款
                p
                  form ng-submit= 'create_or_update()'
                    label for="money" 计划融资
                    .row.collapse
                      .small-1.columns
                        span.prefix ¥
                      .small-11.medium-8.large-6.end.columns
                        input type='text' id='money' ng-model='money_require.money' ng-class='{ error: money_require.errors.money }' placeholder="输入融资额度"
                        small.error ng-show='money_require.errors.money' {{ money_require.errors.money }}
                    label for="share" 出让股份
                    .row.collapse
                      .small-11.medium-3.columns
                        input type='text' id='share' ng-model='money_require.share' ng-class='{ error: money_require.errors.share }' placeholder='建议: 5%-20%'
                        small.error ng-show='money_require.errors.share' {{ money_require.errors.share }}
                      .small-1.large-1.end.columns
                        span.postfix %
                    label for='prevalue' 融资前估值( 自动计算 )
                    .row.collapse
                      .small-11.medium-8.large-6.end.columns
                        input type='text' id='money' ng-value='prevalue() | nfcurrency' disabled='' 
                    label for='deadline' 融资周期
                    .row.collapse
                      .small-11.medium-3.columns
                        input type='text' id='deadline' ng-model='money_require.deadline' ng-class='{ error: money_require.errors.deadline }' placeholder='建议: 30-60 天'
                        small.error ng-show='money_require.errors.deadline' {{ money_require.errors.deadline }}
                      .small-1.large-1.end.columns
                        span.postfix 天
                    label for='maxnp' 限制最大人数
                    .row.collapse
                      .small-12.medium-3.columns
                        input type='text' id='maxnp' ng-model='money_require.maxnp' ng-class='{ error: money_require.errors.maxnp }' placeholder='建议: #{MoneyRequire::NP_MIN} - #{MoneyRequire::NP_MAX} 人'
                        small.error ng-show='money_require.errors.maxnp' {{ money_require.errors.maxnp }}
                      .small-1.large-1.end.columns
                        span.postfix 人
                    p.ng-cloak.success
                      | {{ money_require_success }}
                    button.ng-cloak ng-show='money_require.id' 更新融资
              li 
                h4 法律条款
                ul.no-bullet.ng-cloak
                  - LawIterm.project_law_iterms(@project.id).each_with_index do |law_iterm, i|
                    li.margin-link-wrapper
                      span
                        input type='checkbox' ng-click='toggleLawIterm(#{law_iterm.id})' ng-checked="law_iterm_ids.indexOf(#{law_iterm.id}) != -1"
                      a ng-click='law_iterm_#{i} = ! law_iterm_#{i}' ng-init='law_iterm_#{i} = false' #{law_iterm.title}
                      p.description ng-show='law_iterm_#{i}'
                        | #{law_iterm.description}
                  li.margin-link-wrapper ng-repeat='law_iterm in new_law_iterms'
                    span
                      input type='checkbox' ng-click='toggleLawIterm(law_iterm.id)' ng-checked="law_iterm_ids.indexOf(law_iterm.id) != -1"
                    a ng-click='law_iterm_i = ! law_iterm_i' ng-init='law_iterm_i = false' 
                      | {{ law_iterm.title }}
                    p.description ng-show='law_iterm_i'
                      | {{ law_iterm.description }}
                      
                p
                  a ng-click='hash.new_law_iterm_flag = ! hash.new_law_iterm_flag' 我要添加新的条款
                .row
                  .small-12.medium-6.columns
                    form ng-submit='submit_new_law_iterm()' ng-show='hash.new_law_iterm_flag'
                      input type='text' ng-model='hash.new_law_iterm.title' placeholder='条款标题' ng-class='{ error: hash.new_law_iterm.errors.title }'
                      small.error.ng-cloak ng-show='hash.new_law_iterm.errors.title'
                        | {{ hash.new_law_iterm.errors.title }}
                      textarea ng-model='hash.new_law_iterm.description' placeholder='条款说明' ng-class='{ error: hash.new_law_iterm.errors.description }'
                      small.error.ng-cloak ng-show='hash.new_law_iterm.errors.description'
                        | {{ hash.new_law_iterm.errors.description }}
                      .control-actions
                        button.small 提交
                        a.back ng-click='hash.new_law_iterm_flag = false' 取消
                p.alert
                  | {{ law_iterms_error }}
                p.success
                  | {{ law_iterms_success }}
                button.ng-cloak ng-click='update_law_iterms()' 更新条款
                  
              li
                h4 领投人条款
                label for='carry' Carry收益
                .row.collapse
                  .small-4.columns
                    input id='carry' type='text' placeholder='建议 5% - 20%' ng-model='money_require.carry' ng-class='{ error: carry_error_message }'
                    small.error ng-show='carry_error_message'
                      | {{ carry_error_message }}
                  .small-1.end.columns
                    span.postfix %
                p.alert
                  | 注意: 一旦邀请, 无法修改, 请务必线下确认后再键入.
                form ng-submit='add_leader()'
                  .leader
                    person ng-show='selected_leader()' user='hash.autocomplete_user'
                  .row
                    .small-12.medium-6.end.columns
                      input type='text' id='leader' placeholder='投资人姓名 or 邮箱' ng-model='hash.autocomplete_user' typeahead="user as user.name for user in autocomplete_search($viewValue)" typeahead-template-url="leader_select.html"
                      p.alert ng-show='leader_error_message'
                        | {{ leader_error_message }}
                      button ng-disabled= '! selected_leader()' 确认领投人
      script type='text/ng-template' id='leader_select.html'
        a ng-class='{ disabled: match.model.joined }'
          .row
            .small-3.columns
              img ng-src= ' {{ match.model.avatar }} '
            .small-9.columns
              h6.title
                |{{ match.model.name }} 
  .row.ng-cloak ng-show='money_require.status == "leader_need_confirmed"'
    .small-12.large-10.large-centered.columns
      h4 等待领投人确认
      p 请领投人确认
      p.alert 我们已经通过系统消息告之对方, 请尽快让其登录平台, 确认后融资流程正式开始
      person user='money_require.leader'
  .row.ng-cloak ng-show='money_require.status == "opened"'
    .small-12.large-10.large-centered.columns
      .money_require
        moneyrequire require='money_require' title='"目前融资进度"'
      .invest
        h4.title 融资事件
      .timeline.simple
        - @project.events.default_order.each do |event|
          = render partial: 'timeline/event', locals: { event: event }
  .row.ng-cloak ng-show='money_require.status == "closed"'
    .small-12.large-10.large-centered.columns
      moneyrequire require='money_require' title='"融资已完成"'
